<template>
	<view class="redrain">
    <image src="https://ctyh88.oss-cn-shenzhen.aliyuncs.com/gcn/1597131119227.jpg" mode="widthFix" class="red-top1"></image>
    <view class="btnsred" style="background: linear-gradient(0deg,rgba(240,107,37,1),rgba(238,197,27,1));" @click="openred">马上抢红包</view>
  </view>
</template>

<script>
	export default {
		data() {
			return {
				hid:'',
			};
		},
		onShow:function(){
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../../login/login'
					});
				}
			});
		},
    methods:{
			setAjax(){
				uni.request({
					url: 'https://app.t9y9y9.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.redpaper&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.hid = res.data.hid
						if(res.data.error==1){
							uni.showModal({
							    title: '提示',
							    content: res.data.message,
							    success: function (res) {
							        if (res.confirm) {
							            uni.switchTab({
							                url: '../../../member/member'
							            });
							        } else if (res.cancel) {
							            uni.switchTab({
							                url: '../../../member/member'
							            });
							        }
							    }
							})	
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
      openred(){
				uni.navigateTo({
						url: './redbg?hid='+this.hid,
				});
      }
    }
	}
</script>

<style lang="scss" scoped>

  .redrain{
    height: 100vh;
    width:100%;
    background:linear-gradient(0deg,rgba(255,63,29,1) 0%,rgba(255,133,60,1) 99%);
    // padding: 25rpx;
    .red-top{
      background: url('https://ctyh88.oss-cn-shenzhen.aliyuncs.com/gcn/1597125857776.jpg') no-repeat;
      width: 730rpx;
      height: 560rpx;
      background-size: cover;
      // background-position: center;
    }
    .red-top1{
      width: 730rpx;
    }
    .btnsred{
      width:590rpx;
      height:110rpx;
      background:linear-gradient(0deg,#f7d28f,#f7d28f);
      border-radius:55rpx;
      line-height: 110rpx;
      margin:80rpx auto;
      font-size: 36rpx;
      text-align: center;
      color: #fff;
    }
    // .red-bottom{

    // }
  }
</style>
